const userManage = require('../module/userManage')

// 角色管理：增删改查 / 批量删除
const main_user_manage = async (ctx, next) => {
  // 增加角色
  try {
    const {
      userName,
      // avatar,
      phone,
      email,
      password,
      // address,
      // detailAddress,
      // role
    } = ctx.request.body

    const resCreateUser = await userManage.create({
      userName,
      // avatar,
      phone,
      email,
      password,
      // address,
      // detailAddress,
      // role
    })
    if (resCreateUser){
      ctx.body = {
        code: 0,
        msg: '用户创建成功',
        data: resCreateUser
      }
    } else {
      ctx.body = {
        code: -1,
        msg: '用户创建失败',
        data: []
      }
    }
  } catch (error) {
    ctx.body = {
      code: -1,
      msg: '用户创建失败',
      data: []
    }
  }
}

const main_user_delete = async(ctx, next) => {

}

module.exports = {
  'POST /userCreate': main_user_manage
}